import { TabsState } from "@/redux/interface"
import {createSlice} from "@reduxjs/toolkit"
import { HOME_URL } from "@/config/config"

const tabsState: TabsState = {
    // tabsActive 其实没什么用，使用pathname 就可以了
    tabsActive: HOME_URL,
    tabsList: [{title:"首页", path: HOME_URL}]
}

const tabSlice = createSlice({
    name: "tabs",
    initialState: tabsState,
    reducers: {
        setTabsList(state: TabsState, {payload}) {
            state.tabsList = payload
        },
        setTabsActive(state: TabsState, {payload}) {
            state.tabsActive = payload
        }
    }
})

export const {setTabsActive, setTabsList} = tabSlice.actions
export default tabSlice.reducer